#pragma once

#include <QObject>
#include <QList>
#include <QString>
#include "poco/word.h"
#include "util/usermanager.h"

namespace WordMemory
{

class LocalWordManager : public QObject
{
    Q_OBJECT
public:
    static LocalWordManager &instance();

    bool saveWord(const Word &word);
    QList<Word> loadDownloadedWords();
    bool isWordDownloaded(int wordId) const;
    bool removeWord(int wordId);

signals:
    void downloadedWordsChanged();

private:
    explicit LocalWordManager(QObject *parent = nullptr);
    LocalWordManager(const LocalWordManager &) = delete;
    LocalWordManager &operator=(const LocalWordManager &) = delete;

    QString getStorageFilePath() const;
    bool loadWordsFromFile();
    bool saveWordsToFile() const;

    QList<Word> m_downloadedWords;
    bool m_isLoaded;
};

} // namespace WordMemory
